<template>
	<view class="p30 "> 
		<view class="main ">
			<view v-for="(v,i) in data" :key="i" class="box">
				<view class="topsRecommend">
					<image class="fl" :src="v.logo" mode=""></image>
					<p class="txt fl one">
						#{{v.name}}#
					</p>
					<view @tap="GoJi(v.id)" class="fr">
						进入集市
					</view>
				</view>
				<view  v-if="v.validProducts != '' " class="imgArr">
					<view @tap="GoGoodsDetails(j.id)" v-for="(j,k) in v.validProducts" :key="k">
						<image :src="j.thumbnail"  mode="aspectFill" ></image>
						<p class="one name">{{j.name}} </p>
						<p class="c2 one">￥ {{j.price}} </p>
					</view> 
					<view class="more">

					</view>
				</view>
			</view>
		</view>
		<view v-if="data == '' " class=" dataNone">
			<image src="../../../static/image/huati.png" mode=""></image>
			<p>暂无推荐</p>
		</view>
	</view>
</template>

<script>
	import {
		indexMarkets,marketmarketProducts
	} from '../../../api/api.js'
	import {
		mapState,
		mapActions
	} from "vuex";
	export default {
		data() {
			return {
				stops: 0, 
				pageNumber: 1,
				pageSize: 6,
				data: []
			}
		},
		computed: {
			...mapState(['longitude', 'latitude'])
		}, 
		methods: {
			GoJi(id){ 
				let url = '../ji/ji?id='+id 
				this.$navigateTo(url) 
			},
			checking(){
				if(this.stops == 0){
					this.init()
				}
			},
			inits(){
				this.stops = 0
				this.data = []
				this.pageNumber = 1
				this.init()
			},
			async init() {
				let parameter =  {
					longitude: this.$store.state.longitude,
					latitude:this.$store.state.latitude,
					isIndex:true,
					pageable: {
						pageNumber: this.pageNumber,
						pageSize: this.pageSize
					}
				}
				let datas = await indexMarkets(parameter)
				datas = datas.data
				if (datas.length != this.pageSize) {
					this.stops = 1
				} 
				this.data = [...this.data,...datas]
				this.pageNumber = this.pageNumber + 1
			},
			GoGoodsDetails(id) {
				this.$navigateTo(`../GoodsDetails/GoodsDetails?id=${id}`) 
			}
		}
	}
</script>

<style lang="less" scoped>
	@import './index.less';
</style>
